if(!dojo._hasResource["opm.widgets.Ajax"]){
dojo._hasResource["opm.widgets.Ajax"] = true;
dojo.provide("opm.widgets.Ajax");
dojo.require("dijit._Widget");
dojo.declare("opm.widgets.Ajax",dijit._Widget,
   {
      ajaxUrl:"",
      contentId:"",
      callback:null,
      form:{},
      postData:"",
      constructor:function(args){
         this.setAtts(args);
      },
      setAtts:function(args){
         this.ajaxUrl = args.ajaxUrl;
         this.callback = args.callback; 
         this.contentId = args.contentId;
         this.form = args.form;
         this.postData = args.postData;
      },
      callXhrGet:function(){
         var targetNode = dojo.byId(this.contentId);
         var xhrArgs = {
             url: this.ajaxUrl,
             handleAs: "text",
             callback: this.callback,
             load: function(data) {
               targetNode.innerHTML = data;
               if (this.callback != null){
                  this.callback();
               }
             },
             error: function(error) {
                 targetNode.innerHTML = "An unexpected error occurred: " + error;
             }
         };
         dojo.xhrGet(xhrArgs);
      },
      callXhrGetJson:function(){
         var targetNode = dojo.byId(this.contentId);
         var xhrArgs = {
             url: this.ajaxUrl,
             handleAs: "json",
             callback: this.callback,
             load: function(data) {
               if (this.callback != null){
                  this.callback(data);
               }
             },
             error: function(error) {
                 targetNode.innerHTML = "An unexpected error occurred: " + error;
             }
         };
         dojo.xhrGet(xhrArgs);
      },
      callXhrPostForm:function(){
         var targetNode = dojo.byId(this.contentId);
         var xhrArgs = {
             form: this.form,
             handleAs: "json",
             callback: this.callback,
             load: function(data) {
               if (this.callback != null){
                  this.callback(data);
               }
             },
             error: function(error) {
                 targetNode.innerHTML = "An unexpected error occurred: " + error;
             }
         };
         dojo.xhrPost(xhrArgs);
      },
      callXhrPostText:function(){
         var targetNode = dojo.byId(this.contentId);
         var xhrArgs = {
             url: this.ajaxUrl,
             handleAs: "json",
             callback: this.callback,
             postData: this.postData,
             load: function(data) {
               if (this.callback != null){
                  this.callback(data);
               }
             },
             error: function(error) {
                 targetNode.innerHTML = "An unexpected error occurred: " + error;
             }
         };
         dojo.xhrPost(xhrArgs);
      }
   }
);
}